﻿// --------------------------------------------------------------------------------------------------------------------
// copy right == 2011 Richard Griffin and Ollie Riches
// logger helper class
// author:Alexis(http://www.cnblogs.com/alexis)
// date: 20110922
// --------------------------------------------------------------------------------------------------------------------

using System;

namespace Logging
{
    public class LoggingHelper
    {
        public static string ApplicationName = "TestApp";

        /// <summary>
        /// 记录日志
        /// </summary>
        /// <param name="message">消息</param>
        public static void Log(string message)
        {
            using (var service = new LoggingService(ApplicationName))
            {
                service.Enable();
                service.Write(message);
                service.Dispose();
            }
        }

        /// <summary>
        /// 记录日志
        /// </summary>
        /// <param name="message">消息</param>
        /// <param name="e">异常</param>
        public static void Log(string message, Exception e)
        {
            using (var service = new LoggingService(ApplicationName))
            {
                service.Enable();
                service.Write(message,e);
                service.Dispose();
            }
            
        }

        public static void LogDeviceInfo()
        {
            using (var service = new LoggingService(ApplicationName))
            {
                service.Enable();
                service.WriteDiagnostics();
                service.Dispose();
            }
        }        
    }
}
